package com.platform.api.bzproject.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.platform.api.bzproject.model.BzTalent;
import com.platform.common.core.Result;
import com.platform.common.core.oss.AttachFileService;
import com.platform.security.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author guoyunfei on 2023/9/3 10:49
 * @className FileController
 * @description TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("upload")
public class FileController {

    @Autowired
    private AttachFileService attachFileService;

    /**
     * 文件上传
     * @param file 文件对象
     * @return
     * @throws IOException
     */
    @PostMapping("u/file")
    public Result uploadFile(@RequestParam("file") MultipartFile file) throws IOException {

        String filename = attachFileService.uploadFile(file, null);

        String fileUrl = attachFileService.getDomain() + "/" +filename;;

        return Result.success(fileUrl);
    }

}
